Skip to content

Make yaml output consistent with the json one #2417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2023

Conversation

alessio-perugini
Copy link
Contributor

@alessio-perugini alessio-perugini commented Nov 13, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Instead of using go struct to produce YAML output, we're now generating it starting from the JSON result using sigs.k8s.io/yaml.
pros:

  • We don't have to implement custom Marshaling for YAML object
  • We are guaranteed that the same JSON output matches 1:1 to YAML one
  • We don't risk mismatching key names between JSON and YAML.
  • We don't have to maintain 2 different output formats in many places.

cons:

  • slightly less performant as we're doing a double marshaling

What is the current behavior?

Currently, some values in the JSON output are missing when using the YAML format.

What is the new behavior?

The yaml output is now consistent with the JSON one.

Does this PR introduce a breaking change, and is titled accordingly?

Other information

Copy link

codecov bot commented Nov 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (17f0189) 67.15% compared to head (9de54b7) 67.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2417      +/-   ##
==========================================
+ Coverage   67.15%   67.16%   +0.01%     
==========================================
  Files         210      210              
  Lines       20523    20523              
==========================================
+ Hits        13782    13785       +3     
+ Misses       5602     5600       -2     
+ Partials     1139     1138       -1     
Flag Coverage Δ
unit 67.16% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
internal/cli/feedback/feedback.go 69.78% <ø> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alessio-perugini alessio-perugini marked this pull request as ready for review November 13, 2023 13:35
@alessio-perugini alessio-perugini added the type: enhancement Proposed improvement label Nov 13, 2023
@alessio-perugini alessio-perugini added this to the Arduino CLI v0.36.0 milestone Nov 13, 2023
@alessio-perugini alessio-perugini self-assigned this Nov 13, 2023
Copy link
Contributor

@umbynos umbynos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow I didn't know this existed! I like the approach to the problem

@alessio-perugini alessio-perugini merged commit e9028b9 into master Nov 14, 2023
@alessio-perugini alessio-perugini deleted the add-marshall-json-to-ordered-map branch November 14, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants